<template>
  <div>
    <el-tree
      ref="DeviceGroupTree"
      :data="groupTreeData"
      show-checkbox
      node-key="id"
      check-strictly
      @check="checkGroupNode"
    />
  </div>
</template>

<script>
import { getsearch } from '../../api/uc/search'

export default {
  data() {
    return {
      groupTreeData: [
        {
          id: 3,
          label: '西大门',
          disabled: false,
          children: [
            {
              id: 125,
              label: '2单元',
              disabled: false,
              children: [
                {
                  id: 130,
                  label: '2001',
                  disabled: false,
                  children: []
                },
                {
                  id: 131,
                  label: '2002',
                  disabled: false,
                  children: []
                },
                {
                  id: 132,
                  label: '2003',
                  disabled: false,
                  children: []
                }
              ]
            }
          ]
        }
      ]
    }
  },
  mounted() {
    this.getsearch()
  },
  methods: {
    // 获取数据
    async getsearch() {
      const getdataList = await getsearch()
      this.groupUserTree = getdataList.data.groupUserTree
      this.roleUserTree = getdataList.data.roleUserTree
    },
    checkGroupNode(a, b) {
      if (b.checkedKeys.length > 0) {
        this.$refs.DeviceGroupTree.setCheckedKeys([a.id])
      }
    }
  }
}
</script>

<style>
</style>
